package com.yuanheng100.ems4j.utils;

import com.yuanheng100.ems4j.model.Ems4jDepartment;
import com.yuanheng100.ems4j.model.Ems4jEmployee;

/**
 * Created by jlqian on 2017/3/8.
 */
public class Comparator
{
    public static boolean compareEms4jDepartment(Ems4jDepartment department_1, Ems4jDepartment department_2)
    {
        if (department_1.getId().equals(department_2.getId()) && department_1.getName().equals(department_2.getName()) && department_1.getOrdernum().equals(department_2.getOrdernum()) && department_1.getParentid().equals(department_2.getParentid()))
        {
            return true;
        }
        return false;
    }

    public static boolean compareEms4jEmployee(Ems4jEmployee employee_1, Ems4jEmployee employee_2)
    {
        if (employee_1.getUserid().equals(employee_2.getUserid()) && employee_1.getName().equals(employee_2.getName()) && employee_1.getDepartment().equals(employee_2.getDepartment()) && compare(employee_1.getPosition(), employee_2.getPosition()) && compare(employee_1.getMobile(), employee_2.getMobile()) && compare(employee_1.getEmail(), employee_2.getEmail()) && compare(employee_1.getWeixinid(), employee_2.getWeixinid()))
        {
            return true;
        }
        return false;
    }

    /**
     * 比较是否相同：包含NULL的情况
     *
     * @return
     */
    private static boolean compare(Object o1, Object o2)
    {
        if (o1 == o2)
        {
            return true;
        }
        if (o1 != null && o1.equals(o2))
        {
            return true;
        }
        return false;
    }

}
